// pages/order/order.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentIndex: 0,
    swipertab: [{ name: '待配送', index: 0 }, { name: '配送中', index: 1 }, { name: '已完成', index: 2 }],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {
    this.getDeviceInfo()
    this.orderShow()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  /**
   * 状态栏切换
   */
  tabSwitch: function (e) {
    let that  =this
    if (this.data.currentIndex === e.target.dataset.current) {
      return false
    } else {
      that.setData({
        currentIndex: e.target.dataset.current
      })
    }
  },
  tabChange: function (e) {
    this.setData({
      currentIndex: e.detail.current
    })
    this.orderShow()
  },
  getDeviceInfo: function () {
    let that = this
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          deviceW: res.windowWidth,
          deviceH: res.windowHeight
        })
      }
    })
  },

  orderShow: function () {
    let that = this
    switch (this.data.currentIndex) {
      case 0:
        that.tobeShow()
        break
      case 1:
        that.deliveringShow()
        break
      case 2:
        that.alreadyShow()
        break
    }
  },
 
  tobeShow:function(){
    // console.log(1);
    this.setData({
      tobeDeliveredOrder: [{orderNum:1233455, state:"待配送",url:"/images/oolong.jpg",name:"乌龙茶", size:"150g",quantity:1,money: 150 }],
    })
  },
  deliveringShow: function () {
    this.setData({
      deliveringOrder:[{orderNum:2333455, state:"配送中",url:"https://bkimg.cdn.bcebos.com/pic/728da9773912b31bbb1f06228618367adab4e14e?x-bce-process=image/resize,m_lfit,w_268,limit_1",name:"西山茶", size:"100g",quantity:2,money: 350, }],
    })
  },
  alreadyShow: function(){
    this.setData({
      alreadyDoneOrder: [{orderNum:3100155, state:"已完成",url:"https://bkimg.cdn.bcebos.com/pic/0823dd54564e92582d512f3c9082d158cdbf4eff?x-bce-process=image/watermark,image_d2F0ZXIvYmFpa2UyNzI=,g_7,xp_5,yp_5",name:"昭平茶", size:"50g",quantity:1,money: 50, }]
    })
  },
 
})